﻿using APP.HELPER.Data.Helper;
using APP.HELPER.Utils;
using System; using Extra.ERP;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;

namespace HRM.CORE
{
    public class DIC_TIMEKEEPER_FORMULA
    {
        private DateTime m_BeginTimeHoliday;
        private DateTime m_BeginTimeNight;
        private DateTime m_BeginTimeSaturday;
        private DateTime m_BeginTimeSunday;
        private DateTime m_EndTimeNight;
        private Guid m_FormulaID;
        private bool m_IsOvertimeHoliday;
        private bool m_IsOvertimeSaturday;
        private bool m_IsOvertimeSunday;
        private int m_MaximumMinuteHoliday;
        private int m_MaximumMinuteSaturday;
        private int m_MaximumMinuteSunday;
        private int m_MinimumMinuteHoliday;
        private int m_MinimumMinuteSaturday;
        private int m_MinimumMinuteSunday;
        private double m_NumberDayStandard;
        private double m_NumberHourStandard;
        private int m_OvertimeHolidayType;
        private int m_OvertimeSaturdayType;
        private int m_OvertimeSundayType;

        public DIC_TIMEKEEPER_FORMULA()
        {
            this.m_FormulaID = Guid.Empty;
            this.m_IsOvertimeSaturday = true;
            this.m_OvertimeSaturdayType = 0;
            this.m_BeginTimeSaturday = DateTime.Now;
            this.m_MinimumMinuteSaturday = 0;
            this.m_MaximumMinuteSaturday = 0;
            this.m_IsOvertimeSunday = true;
            this.m_OvertimeSundayType = 0;
            this.m_BeginTimeSunday = DateTime.Now;
            this.m_MinimumMinuteSunday = 0;
            this.m_MaximumMinuteSunday = 0;
            this.m_IsOvertimeHoliday = true;
            this.m_OvertimeHolidayType = 0;
            this.m_BeginTimeHoliday = DateTime.Now;
            this.m_MinimumMinuteHoliday = 0;
            this.m_MaximumMinuteHoliday = 0;
            this.m_BeginTimeNight = DateTime.Now;
            this.m_EndTimeNight = DateTime.Now;
            this.m_NumberDayStandard = 0.0;
            this.m_NumberHourStandard = 0.0;
        }

        public DIC_TIMEKEEPER_FORMULA(Guid FormulaID, bool IsOvertimeSaturday, int OvertimeSaturdayType, DateTime BeginTimeSaturday, int MinimumMinuteSaturday, int MaximumMinuteSaturday, bool IsOvertimeSunday, int OvertimeSundayType, DateTime BeginTimeSunday, int MinimumMinuteSunday, int MaximumMinuteSunday, bool IsOvertimeHoliday, int OvertimeHolidayType, DateTime BeginTimeHoliday, int MinimumMinuteHoliday, int MaximumMinuteHoliday, DateTime BeginTimeNight, DateTime EndTimeNight, double NumberDayStandard, double NumberHourStandard)
        {
            this.m_FormulaID = FormulaID;
            this.m_IsOvertimeSaturday = IsOvertimeSaturday;
            this.m_OvertimeSaturdayType = OvertimeSaturdayType;
            this.m_BeginTimeSaturday = BeginTimeSaturday;
            this.m_MinimumMinuteSaturday = MinimumMinuteSaturday;
            this.m_MaximumMinuteSaturday = MaximumMinuteSaturday;
            this.m_IsOvertimeSunday = IsOvertimeSunday;
            this.m_OvertimeSundayType = OvertimeSundayType;
            this.m_BeginTimeSunday = BeginTimeSunday;
            this.m_MinimumMinuteSunday = MinimumMinuteSunday;
            this.m_MaximumMinuteSunday = MaximumMinuteSunday;
            this.m_IsOvertimeHoliday = IsOvertimeHoliday;
            this.m_OvertimeHolidayType = OvertimeHolidayType;
            this.m_BeginTimeHoliday = BeginTimeHoliday;
            this.m_MinimumMinuteHoliday = MinimumMinuteHoliday;
            this.m_MaximumMinuteHoliday = MaximumMinuteHoliday;
            this.m_BeginTimeNight = BeginTimeNight;
            this.m_EndTimeNight = EndTimeNight;
            this.m_NumberDayStandard = NumberDayStandard;
            this.m_NumberHourStandard = NumberHourStandard;
        }

        public string Get()
        {
            string str = "";
            SqlHelper helper = new SqlHelper();
            SqlDataReader reader = helper.ExecuteReader("DIC_TIMEKEEPER_FORMULA_Get");
            if (reader != null)
            {
                while (reader.Read())
                {
                    this.m_FormulaID = reader.GetGuid(reader.GetOrdinal("FormulaID"));
                    this.m_IsOvertimeSaturday = Convert.ToBoolean(reader["IsOvertimeSaturday"]);
                    this.m_OvertimeSaturdayType = Convert.ToInt32(reader["OvertimeSaturdayType"]);
                    this.m_BeginTimeSaturday = Convert.ToDateTime(reader["BeginTimeSaturday"]);
                    this.m_MinimumMinuteSaturday = Convert.ToInt32(reader["MinimumMinuteSaturday"]);
                    this.m_MaximumMinuteSaturday = Convert.ToInt32(reader["MaximumMinuteSaturday"]);
                    this.m_IsOvertimeSunday = Convert.ToBoolean(reader["IsOvertimeSunday"]);
                    this.m_OvertimeSundayType = Convert.ToInt32(reader["OvertimeSundayType"]);
                    this.m_BeginTimeSunday = Convert.ToDateTime(reader["BeginTimeSunday"]);
                    this.m_MinimumMinuteSunday = Convert.ToInt32(reader["MinimumMinuteSunday"]);
                    this.m_MaximumMinuteSunday = Convert.ToInt32(reader["MaximumMinuteSunday"]);
                    this.m_IsOvertimeHoliday = Convert.ToBoolean(reader["IsOvertimeHoliday"]);
                    this.m_OvertimeHolidayType = Convert.ToInt32(reader["OvertimeHolidayType"]);
                    this.m_BeginTimeHoliday = Convert.ToDateTime(reader["BeginTimeHoliday"]);
                    this.m_MinimumMinuteHoliday = Convert.ToInt32(reader["MinimumMinuteHoliday"]);
                    this.m_MaximumMinuteHoliday = Convert.ToInt32(reader["MaximumMinuteHoliday"]);
                    this.m_BeginTimeNight = Convert.ToDateTime(reader["BeginTimeNight"]);
                    this.m_EndTimeNight = Convert.ToDateTime(reader["EndTimeNight"]);
                    this.m_NumberDayStandard = Convert.ToInt32(reader["NumberDayStandard"]);
                    this.m_NumberHourStandard = Convert.ToInt32(reader["NumberHourStandard"]);
                    str = "OK";
                }
                reader.Close();
                helper.Close();
                reader = null;
            }
            return str;
        }

        public DataTable GetList()
        {
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteDataTable("DIC_TIMEKEEPER_FORMULA_GetList");
        }

        public double NumberNightHour(DateTime dt1, DateTime dt2)
        {
            return MyDateTime.NumberHour(dt1, dt2);
        }

        public string Update()
        {
            string[] myParams = new string[] { 
                "@FormulaID", "@IsOvertimeSaturday", "@OvertimeSaturdayType", "@BeginTimeSaturday", "@MinimumMinuteSaturday", "@MaximumMinuteSaturday", "@IsOvertimeSunday", "@OvertimeSundayType", "@BeginTimeSunday", "@MinimumMinuteSunday", "@MaximumMinuteSunday", "@IsOvertimeHoliday", "@OvertimeHolidayType", "@BeginTimeHoliday", "@MinimumMinuteHoliday", "@MaximumMinuteHoliday", 
                "@BeginTimeNight", "@EndTimeNight", "@NumberDayStandard", "@NumberHourStandard"
             };
            object[] myValues = new object[] { 
                this.m_FormulaID, this.m_IsOvertimeSaturday, this.m_OvertimeSaturdayType, this.m_BeginTimeSaturday, this.m_MinimumMinuteSaturday, this.m_MaximumMinuteSaturday, this.m_IsOvertimeSunday, this.m_OvertimeSundayType, this.m_BeginTimeSunday, this.m_MinimumMinuteSunday, this.m_MaximumMinuteSunday, this.m_IsOvertimeHoliday, this.m_OvertimeHolidayType, this.m_BeginTimeHoliday, this.m_MinimumMinuteHoliday, this.m_MaximumMinuteHoliday, 
                this.m_BeginTimeNight, this.m_EndTimeNight, this.m_NumberDayStandard, this.m_NumberHourStandard
             };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("DIC_TIMEKEEPER_FORMULA_Update", myParams, myValues);
        }

        public string Update(Guid FormulaID, bool IsOvertimeSaturday, int OvertimeSaturdayType, DateTime BeginTimeSaturday, int MinimumMinuteSaturday, int MaximumMinuteSaturday, bool IsOvertimeSunday, int OvertimeSundayType, DateTime BeginTimeSunday, int MinimumMinuteSunday, int MaximumMinuteSunday, bool IsOvertimeHoliday, int OvertimeHolidayType, DateTime BeginTimeHoliday, int MinimumMinuteHoliday, int MaximumMinuteHoliday, DateTime BeginTimeNight, DateTime EndTimeNight, double NumberDayStandard, double NumberHourStandard)
        {
            string[] myParams = new string[] { 
                "@FormulaID", "@IsOvertimeSaturday", "@OvertimeSaturdayType", "@BeginTimeSaturday", "@MinimumMinuteSaturday", "@MaximumMinuteSaturday", "@IsOvertimeSunday", "@OvertimeSundayType", "@BeginTimeSunday", "@MinimumMinuteSunday", "@MaximumMinuteSunday", "@IsOvertimeHoliday", "@OvertimeHolidayType", "@BeginTimeHoliday", "@MinimumMinuteHoliday", "@MaximumMinuteHoliday", 
                "@BeginTimeNight", "@EndTimeNight", "@NumberDayStandard", "@NumberHourStandard"
             };
            object[] myValues = new object[] { 
                FormulaID, IsOvertimeSaturday, OvertimeSaturdayType, BeginTimeSaturday, MinimumMinuteSaturday, MaximumMinuteSaturday, IsOvertimeSunday, OvertimeSundayType, BeginTimeSunday, MinimumMinuteSunday, MaximumMinuteSunday, IsOvertimeHoliday, OvertimeHolidayType, BeginTimeHoliday, MinimumMinuteHoliday, MaximumMinuteHoliday, 
                BeginTimeNight, EndTimeNight, NumberDayStandard, NumberHourStandard
             };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("DIC_TIMEKEEPER_FORMULA_Update", myParams, myValues);
        }

        public string Update(SqlConnection myConnection, Guid FormulaID, bool IsOvertimeSaturday, int OvertimeSaturdayType, DateTime BeginTimeSaturday, int MinimumMinuteSaturday, int MaximumMinuteSaturday, bool IsOvertimeSunday, int OvertimeSundayType, DateTime BeginTimeSunday, int MinimumMinuteSunday, int MaximumMinuteSunday, bool IsOvertimeHoliday, int OvertimeHolidayType, DateTime BeginTimeHoliday, int MinimumMinuteHoliday, int MaximumMinuteHoliday, DateTime BeginTimeNight, DateTime EndTimeNight, double NumberDayStandard, double NumberHourStandard)
        {
            string[] myParams = new string[] { 
                "@FormulaID", "@IsOvertimeSaturday", "@OvertimeSaturdayType", "@BeginTimeSaturday", "@MinimumMinuteSaturday", "@MaximumMinuteSaturday", "@IsOvertimeSunday", "@OvertimeSundayType", "@BeginTimeSunday", "@MinimumMinuteSunday", "@MaximumMinuteSunday", "@IsOvertimeHoliday", "@OvertimeHolidayType", "@BeginTimeHoliday", "@MinimumMinuteHoliday", "@MaximumMinuteHoliday", 
                "@BeginTimeNight", "@EndTimeNight", "@NumberDayStandard", "@NumberHourStandard"
             };
            object[] myValues = new object[] { 
                FormulaID, IsOvertimeSaturday, OvertimeSaturdayType, BeginTimeSaturday, MinimumMinuteSaturday, MaximumMinuteSaturday, IsOvertimeSunday, OvertimeSundayType, BeginTimeSunday, MinimumMinuteSunday, MaximumMinuteSunday, IsOvertimeHoliday, OvertimeHolidayType, BeginTimeHoliday, MinimumMinuteHoliday, MaximumMinuteHoliday, 
                BeginTimeNight, EndTimeNight, NumberDayStandard, NumberHourStandard
             };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myConnection, "DIC_TIMEKEEPER_FORMULA_Update", myParams, myValues);
        }

        public string Update(SqlTransaction myTransaction, Guid FormulaID, bool IsOvertimeSaturday, int OvertimeSaturdayType, DateTime BeginTimeSaturday, int MinimumMinuteSaturday, int MaximumMinuteSaturday, bool IsOvertimeSunday, int OvertimeSundayType, DateTime BeginTimeSunday, int MinimumMinuteSunday, int MaximumMinuteSunday, bool IsOvertimeHoliday, int OvertimeHolidayType, DateTime BeginTimeHoliday, int MinimumMinuteHoliday, int MaximumMinuteHoliday, DateTime BeginTimeNight, DateTime EndTimeNight, double NumberDayStandard, double NumberHourStandard)
        {
            string[] myParams = new string[] { 
                "@FormulaID", "@IsOvertimeSaturday", "@OvertimeSaturdayType", "@BeginTimeSaturday", "@MinimumMinuteSaturday", "@MaximumMinuteSaturday", "@IsOvertimeSunday", "@OvertimeSundayType", "@BeginTimeSunday", "@MinimumMinuteSunday", "@MaximumMinuteSunday", "@IsOvertimeHoliday", "@OvertimeHolidayType", "@BeginTimeHoliday", "@MinimumMinuteHoliday", "@MaximumMinuteHoliday", 
                "@BeginTimeNight", "@EndTimeNight", "@NumberDayStandard", "@NumberHourStandard"
             };
            object[] myValues = new object[] { 
                FormulaID, IsOvertimeSaturday, OvertimeSaturdayType, BeginTimeSaturday, MinimumMinuteSaturday, MaximumMinuteSaturday, IsOvertimeSunday, OvertimeSundayType, BeginTimeSunday, MinimumMinuteSunday, MaximumMinuteSunday, IsOvertimeHoliday, OvertimeHolidayType, BeginTimeHoliday, MinimumMinuteHoliday, MaximumMinuteHoliday, 
                BeginTimeNight, EndTimeNight, NumberDayStandard, NumberHourStandard
             };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myTransaction, "DIC_TIMEKEEPER_FORMULA_Update", myParams, myValues);
        }

        [DisplayName("BeginTimeHoliday"), Category("Column")]
        public DateTime BeginTimeHoliday
        {
            get
            {
                return this.m_BeginTimeHoliday;
            }
            set
            {
                this.m_BeginTimeHoliday = value;
            }
        }

        [Category("Column"), DisplayName("BeginTimeNight")]
        public DateTime BeginTimeNight
        {
            get
            {
                return this.m_BeginTimeNight;
            }
            set
            {
                this.m_BeginTimeNight = value;
            }
        }

        [Category("Column"), DisplayName("BeginTimeSaturday")]
        public DateTime BeginTimeSaturday
        {
            get
            {
                return this.m_BeginTimeSaturday;
            }
            set
            {
                this.m_BeginTimeSaturday = value;
            }
        }

        [DisplayName("BeginTimeSunday"), Category("Column")]
        public DateTime BeginTimeSunday
        {
            get
            {
                return this.m_BeginTimeSunday;
            }
            set
            {
                this.m_BeginTimeSunday = value;
            }
        }

        [DisplayName("EndTimeNight"), Category("Column")]
        public DateTime EndTimeNight
        {
            get
            {
                return this.m_EndTimeNight;
            }
            set
            {
                this.m_EndTimeNight = value;
            }
        }

        [DisplayName("FormulaID"), Category("Primary Key")]
        public Guid FormulaID
        {
            get
            {
                return this.m_FormulaID;
            }
            set
            {
                this.m_FormulaID = value;
            }
        }

        [DisplayName("IsOvertimeHoliday"), Category("Column")]
        public bool IsOvertimeHoliday
        {
            get
            {
                return this.m_IsOvertimeHoliday;
            }
            set
            {
                this.m_IsOvertimeHoliday = value;
            }
        }

        [DisplayName("IsOvertimeSaturday"), Category("Column")]
        public bool IsOvertimeSaturday
        {
            get
            {
                return this.m_IsOvertimeSaturday;
            }
            set
            {
                this.m_IsOvertimeSaturday = value;
            }
        }

        [DisplayName("IsOvertimeSunday"), Category("Column")]
        public bool IsOvertimeSunday
        {
            get
            {
                return this.m_IsOvertimeSunday;
            }
            set
            {
                this.m_IsOvertimeSunday = value;
            }
        }

        [Category("Column"), DisplayName("MaximumMinuteHoliday")]
        public int MaximumMinuteHoliday
        {
            get
            {
                return this.m_MaximumMinuteHoliday;
            }
            set
            {
                this.m_MaximumMinuteHoliday = value;
            }
        }

        [Category("Column"), DisplayName("MaximumMinuteSaturday")]
        public int MaximumMinuteSaturday
        {
            get
            {
                return this.m_MaximumMinuteSaturday;
            }
            set
            {
                this.m_MaximumMinuteSaturday = value;
            }
        }

        [Category("Column"), DisplayName("MaximumMinuteSunday")]
        public int MaximumMinuteSunday
        {
            get
            {
                return this.m_MaximumMinuteSunday;
            }
            set
            {
                this.m_MaximumMinuteSunday = value;
            }
        }

        [Category("Column"), DisplayName("MinimumMinuteHoliday")]
        public int MinimumMinuteHoliday
        {
            get
            {
                return this.m_MinimumMinuteHoliday;
            }
            set
            {
                this.m_MinimumMinuteHoliday = value;
            }
        }

        [DisplayName("MinimumMinuteSaturday"), Category("Column")]
        public int MinimumMinuteSaturday
        {
            get
            {
                return this.m_MinimumMinuteSaturday;
            }
            set
            {
                this.m_MinimumMinuteSaturday = value;
            }
        }

        [DisplayName("MinimumMinuteSunday"), Category("Column")]
        public int MinimumMinuteSunday
        {
            get
            {
                return this.m_MinimumMinuteSunday;
            }
            set
            {
                this.m_MinimumMinuteSunday = value;
            }
        }

        [Category("Column"), DisplayName("NumberDayStandard")]
        public double NumberDayStandard
        {
            get
            {
                return this.m_NumberDayStandard;
            }
            set
            {
                this.m_NumberDayStandard = value;
            }
        }

        [Category("Column"), DisplayName("NumberHourStandard")]
        public double NumberHourStandard
        {
            get
            {
                return this.m_NumberHourStandard;
            }
            set
            {
                this.m_NumberHourStandard = value;
            }
        }

        [Category("Column"), DisplayName("OvertimeHolidayType")]
        public int OvertimeHolidayType
        {
            get
            {
                return this.m_OvertimeHolidayType;
            }
            set
            {
                this.m_OvertimeHolidayType = value;
            }
        }

        [DisplayName("OvertimeSaturdayType"), Category("Column")]
        public int OvertimeSaturdayType
        {
            get
            {
                return this.m_OvertimeSaturdayType;
            }
            set
            {
                this.m_OvertimeSaturdayType = value;
            }
        }

        [DisplayName("OvertimeSundayType"), Category("Column")]
        public int OvertimeSundayType
        {
            get
            {
                return this.m_OvertimeSundayType;
            }
            set
            {
                this.m_OvertimeSundayType = value;
            }
        }

        public string ProductName
        {
            get
            {
                return "Class DIC_TIMEKEEPER_FORMULA";
            }
        }

        public string ProductVersion
        {
            get
            {
                return "1.0.0.0";
            }
        }
    }
}

